﻿@model PostCommentModel

@{

	if (Model.ViewMode == PostCommentModel.ViewType.PageView) {
		Layout = CarrotLayout.Popup;
	}

	ViewBag.Title = "Comment Add/Edit";

	string cancelToUrl = Model.Comment.ContentType == ContentPageType.PageType.BlogEntry ?
						SiteFilename.BlogPostCommentIndexURL : SiteFilename.PageCommentIndexURL;

	if (Model.ViewMode == PostCommentModel.ViewType.PageView) {
		cancelToUrl = String.Format("{0}/{1}", cancelToUrl, Model.Root_ContentID);
	}
}
<div>
	@Html.Partial("_displayErrorPopupButton")
	<br />
	<br />
</div>
@using (Html.BeginForm()) {
	@Html.AntiForgeryToken()

	<fieldset style="width: 725px;">
		<legend>
			<label>
				Page Info
			</label>
		</legend>
		<table style="width: 700px;">
			<tr>
				<td style="width: 125px;" class="tablecaption">
					title:
				</td>
				<td>
					@Model.Comment.NavMenuText
				</td>
			</tr>
			<tr>
				<td class="tablecaption">
					filename:
				</td>
				<td>
					@Model.Comment.FileName
					&nbsp;&nbsp;
					<a id="lnkPage" href="@Model.Comment.FileName" target="_blank">
						<img class="imgNoBorder" src="~/Assets/Admin/Images/html2.png"
							 title="Visit page" alt="Visit page" />
					</a>
				</td>
			</tr>
		</table>
	</fieldset>
	<fieldset style="width: 725px;">
		<legend>
			<label>
				Comment
			</label>
		</legend>
		<table style="width: 700px;">
			<tr>
				<td style="width: 150px;" class="tablecaption">
					IP address:
				</td>
				<td>
					@Model.Comment.CommenterIP
				</td>
			</tr>
			<tr>
				<td class="tablecaption">
					date:
				</td>
				<td>
					@Model.Comment.CreateDate
				</td>
			</tr>
			<tr>
				<td class="tablecaption">
					email:
				</td>
				<td>
					@Html.TextBoxFor(m => m.Comment.CommenterEmail, new { size = "60", @class = "form-control-xlg" })
					@Html.ValidationMessageFor(m => m.Comment.CommenterEmail, "", new { @class = "validationError" })
				</td>
			</tr>
			<tr>
				<td class="tablecaption">
					name:
				</td>
				<td>
					@Html.TextBoxFor(m => m.Comment.CommenterName, new { size = "60", @class = "form-control-xlg" })
					@Html.ValidationMessageFor(m => m.Comment.CommenterName, "", new { @class = "validationError" })
				</td>
			</tr>
			<tr>
				<td class="tablecaption">
					url:
				</td>
				<td>
					@Html.TextBoxFor(m => m.Comment.CommenterURL, new { size = "60", @class = "form-control-xlg" })
					@Html.ValidationMessageFor(m => m.Comment.CommenterURL, "", new { @class = "validationError" })
				</td>
			</tr>
			<tr>
				<td class="tablecaption">
					&nbsp;
				</td>
				<td>
					<div class="table-subblock">
						<b class="caption">approved:</b>&nbsp;&nbsp;
						@Html.CheckBoxFor(m => m.Comment.IsApproved)
					</div>
					<div class="table-subblock">
						<b class="caption">spam:</b>&nbsp;&nbsp;
						@Html.CheckBoxFor(m => m.Comment.IsSpam)
					</div>
				</td>
			</tr>
			<tr>
				<td class="tablecaption">
					comment:
				</td>
				<td>
					@Html.ValidationMessageFor(m => m.Comment.PostCommentText, "", new { @class = "validationError" })
					@Html.TextAreaFor(m => m.Comment.PostCommentText, new { rows = "10", cols = "75", @class = "form-control-xxlg" })
				</td>
			</tr>
		</table>
	</fieldset>

	<input type="button" name="btnSaveButton" value="Save" onclick="SubmitPage();" id="btnSaveButton" /> <text>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </text>
	<input type="button" id="btnCancel" value="Cancel" onclick="cancelEditing()" /> <text>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </text>
	<input type="button" name="btnDeleteButton" value="Delete" onclick="return DeleteItem();" id="btnDeleteButton" />
	<br />
	<div style="display: none;">
		@Html.HiddenFor(m => m.Comment.ContentCommentID)
		@Html.HiddenFor(m => m.Comment.CommenterIP)
		@Html.HiddenFor(m => m.Comment.CreateDate)

		@Html.HiddenFor(m => m.Comment.NavMenuText)
		@Html.HiddenFor(m => m.Comment.FileName)
		@Html.HiddenFor(m => m.Comment.Root_ContentID)
		@Html.HiddenFor(m => m.Comment.ContentType)

		@Html.HiddenFor(m => m.ViewMode)
		@Html.HiddenFor(m => m.Root_ContentID)

		<input type="submit" name="btnSave" value="Save" id="btnSave" />

		<div id="formPrettyValidationSummary">
			@Html.ValidationSummary(true, "")
		</div>
	</div>

}

<div style="display: none;">
	@using (Html.BeginForm("DeleteCommentAddEdit", RouteConfig.AdminCtrlr)) {
		@Html.AntiForgeryToken()

		@Html.HiddenFor(m => m.Comment.ContentCommentID)
		@Html.HiddenFor(m => m.Comment.Root_ContentID)
		@Html.HiddenFor(m => m.Comment.ContentType)

		@Html.HiddenFor(m => m.ViewMode)
		@Html.HiddenFor(m => m.Root_ContentID)

		<input type="submit" name="btnDelete" value="Delete" id="btnDelete" />
	}
</div>

<script type="text/javascript">

	function DeleteItem() {
		var opts = {
			"No": function () { cmsAlertModalClose(); },
			"Yes": function () { ClickDeleteItem(); }
		};

		cmsAlertModalSmallBtns('Are you sure you want to delete this comment?', opts);

		return false;
	}

	function ClickDeleteItem() {
		$('#btnDelete').click();
	}

	function SubmitPage() {
		setTimeout("ClickBtn();", 250);
	}
	function ClickBtn() {
		$('#btnSave').click();
	}

	function cancelEditing() {
		window.setTimeout("location.href = '@cancelToUrl';", 250);
	}
</script>